<?php
/* This is all of the parsing stuff */


/* adjust include_path to include PEAR */
ini_set('include_path', ini_get('include_path').':/home/webluke/public_html/pear/');

/* all your errors are belong to us */
//error_reporting(E_ALL);

/* require PEAR and the parser */
require_once('PEAR.php');
require_once('HTML/BBCodeParser.php');

/* get options from the ini file */
$config = parse_ini_file('BBCodeParser.ini', true);
$options = &PEAR::getStaticProperty('HTML_BBCodeParser', '_options');
$options = $config['HTML_BBCodeParser'];
unset($options);

function nl($str) {
		 $str = nl2br($str);
		 return $str;
}

function bbc($str) {
		 $str = HTML_BBCodeParser::staticQparse($str);
		 return $str;
}

function parse($str) {
		 /* easy parsing for diffrent strings... */
		 $str = bbc($str);
		 $str = nl($str);
		 
		 /* -- OLD Parsing removed for PEAR::HTML_BBCodeParser 
		 $str = str_replace (array("[B]", "[b]"), "<b>", $str);
		 $str = str_replace (array("[/B]", "[/b]"), "</b>", $str);
		 $str = str_replace (array("[I]", "[i]"), "<i>", $str);
		 $str = str_replace (array("[/I]", "[/i]"), "</i>", $str);
		 $str = str_replace (array("[U]", "[u]"), "<u>", $str);
		 $str = str_replace (array("[/U]", "[/u]"), "</u>", $str);
		 $str = str_replace (array("[NL]", "[nl]", ";"), "<br />\n", $str);
		 $str = str_replace (array("[LIST]", "[list]"), "<ul>\n", $str);
		 $str = str_replace (array("[/LIST]", "[/list]"), "</ul>\n", $str);
		 $str = str_replace (array("[LIST=1]", "[list=1]"), "<ol>\n", $str);
		 $str = str_replace (array("[/LIST=1]", "[/list=1]"), "</ol>\n", $str);
		 $str = str_replace (array("[LIST=a]", "[list=a]"), "<ol type=\"A\">\n", $str);
		 $str = str_replace (array("[/LIST=a]", "[/list=a]"), "</ol>\n", $str);
		 $str = str_replace ("[*]", "<li>\n", $str);
		 $str = str_replace ("[/*]", "</li>\n", $str);*/
		 
		 /* always return your functions to were they came from :D */
		 return $str;
}
?>